﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using E_Shop.Common;
using ESHOP.Domain;
using ESHOP.DAO;
namespace E_Shop
{
    public partial class CompanyProductManage : Authentication
    {
        private readonly SanPhamDAO _sanphamdao = new SanPhamDAO();
        protected void Page_Load(object sender, EventArgs e)
        {
            Binddataforgrid();
        }
        public void Binddataforgrid()
        {
            var list = _sanphamdao.GetListByCompanyID(Acount.MACT);
            gvList.DataSource = list;
            gvList.DataBind();
            UpGrid.Update();
        }

        protected void gvList_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {

        }

        protected void gvList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            var id = e.CommandArgument;
            var name = e.CommandName.ToString();
            switch (name)
            {
                case "deleteproduct":
                    {

                        _sanphamdao.Delete(id.ToString());
                        Binddataforgrid();
                        break;
                    }
                case "detailproduct":
                    {
                        break;
                    }
            }

        }

        protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
        {

        }
    }
}